/*
 * @lc app=leetcode.cn id=1752 lang=typescript
 *
 * [1752] 检查数组是否经排序和轮转得到
 */

// @lc code=start
function check(nums: number[]): boolean {
    let min = nums[0];
    let index = -1;
    for (let i = 1; i < nums.length; i++) {
        const prev = nums[i - 1];
        const element = nums[i];
        if (prev <= element) {
            if (index !== -1 && element > min) {
                return false;
            }
        } else {
            if (index !== -1 || element > min) return false;
            index = i;
        }
    }

    return true;
}
// @lc code=end
